if(!dojo._hasResource["market.widgets.GenericFormDialog"]){
dojo._hasResource["market.widgets.GenericFormDialog"] = true;
dojo.provide("market.widgets.GenericFormDialog");
dojo.require("dijit._Widget");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.declare("market.widgets.GenericFormDialog",dijit._Widget,
{
   contentId:"",
   widgetId:"",
   dialogWidgetId:"_genericFormWiget_Dialog",
   title:"",
   style:"",
   form:{},
   content:"",
   btnCancelId:"btnCancel",
   btnYesId:"btnYes",
   handleClickBtnYes:null,
   systemDialog:null,
   constructor:function(args){
      this.setAtts(args);
   },
   setAtts:function(args){
      this.contentId = args.contentId;
      this.title = (args.title==null)?dojo.getNodeProp(dojo.byId(this.contentId),"title"):args.title;
      this.style = (args.style==null)?"width: 400px":args.style;
      this.content = (args.content==null)?dojo.byId(this.contentId).innerHTML:args.content;
   },
   empty:function (){
       dijit.registry.remove(this.dialogWidgetId);
       dijit.registry.remove(this.btnYesId);
       dijit.registry.remove(this.btnCancelId);
   },
   showDialog:function(){
      this.empty();
      var dialogContentId = "_genericFormDialog_" + this.dialogWidgetId;
      if (dojo.byId(dialogContentId) == null){
         var childDiv = dojo.doc.createElement("div");
         dojo.attr(childDiv, "id", dialogContentId);
         dojo.byId(this.contentId).parentNode.appendChild(childDiv);
         dojo.byId(dialogContentId).innerHTML = '<div id="'+this.dialogWidgetId+'"></div>';
      }
      var dialog = new dijit.Dialog({
         title:this.title,
         style:this.style,
         content:this._genericContent()
      },this.dialogWidgetId);
      dialog.show();
      dojo.query('#'+this.dialogWidgetId+' [id="'+this.btnCancelId+'"]').connect("onclick",function(evt){
         dialog.hide();
      });
      var _handleClickBtnYes = this.handleClickBtnYes;
      dojo.query('#'+this.dialogWidgetId+' [id="'+this.btnYesId+'"]').connect("onclick",function(evt){
         if (_handleClickBtnYes != null){
            _handleClickBtnYes.callBackFunction();
         }
      });
      this.systemDialog = dialog;
   },
   close:function(){
      this.systemDialog.hide();
   },
   callPostText:function(dataform){
      var localDialog = this;
      var ajaxUrl = dataform.ajaxUrl;
      OPM.ajaxWidget({
         ajaxUrl: ajaxUrl,
         callback: function (data){
            if (dataform.handleSuccess == null)
               localDialog.close();
            else
               dataform.handleSuccess(data);
         }
      },this.contentId).callXhrPostText();
   },
   _genericContent:function(){
      var content = '<div>'+this.content+'<div class="divButton"><input id="'+this.btnYesId+'" type="button" dojoType="dijit.form.Button" label="Yes"/><input id="'+this.btnCancelId+'" type="button" dojoType="dijit.form.Button" label="Cancel"/></div></div>';
      return content;
   }
}
);
}